// Hardware file header
//

#ifndef HARDWARE_H
#define HARDWARE_H

// Serial output lines
//
#DEFINE SER 		PIN_A4
#DEFINE SCL 		PIN_A3
#DEFINE SCK 		PIN_A2
#DEFINE RCK 		PIN_A1

// Control knob lines
//
#DEFINE ENC_A 		PIN_B1
#DEFINE ENC_B 		PIN_B0
#DEFINE BTN 		PIN_B2

// Other IO lines
//
#DEFINE TRIGGER		PIN_B3
#DEFINE RELAY		PIN_A0

// Encoder state machine states.
//
#DEFINE ENC_CW 		1
#DEFINE ENC_CCW 	2
#DEFINE ENC_MIDDLE	4
#DEFINE ENC_REST	0
#DEFINE ENC_ERROR	99

// Encoder Pushbutton bits
//
#DEFINE LONGPUSH		1500

enum PushType {on, off, push_held};


// Struct for the encoder state machine
//
typedef struct
{
	char direction;
	char last_position;
	char current_position;
} EncoderStateStruct;

void InitEncoderStateStruct(EncoderStateStruct * ENCODER);
signed int ENC_Scan( EncoderStateStruct * ENCODER );
void reset595( void );
void ShiftOut( char DatToWrite );
void SetUnusedPins( void );
char ENC_Read( void );
void Set_Rel( short rel_state );
short TrigState( void );
short EncButton( void );
PushType MultiPushButton( void );
void WaitPB_Release(void);

#include "Hardware.c"
#endif